package com.moter.demo01.juc;

import java.util.concurrent.*;

public class MyCallable implements Callable<Integer> {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable callable = new MyCallable();
        FutureTask<Integer> futureTask = new FutureTask<>(callable);
        new Thread(futureTask).start();
        Integer integer = futureTask.get();//会阻塞 ，等待线程执行完毕
        System.out.println(integer);
    }

    @Override
    public Integer call() throws Exception {
        System.out.println("callable()");
        TimeUnit.SECONDS.sleep(5);
        return 11405071;
    }
}
